package com.ruicar.afs.cloud.apply.archive.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruicar.afs.cloud.apply.archive.condition.MortgageCondition;
import com.ruicar.afs.cloud.apply.archive.service.MortgageService;
import com.ruicar.afs.cloud.archive.dto.MortgageDto;
import com.ruicar.afs.cloud.common.core.query.QueryCondition;
import com.ruicar.afs.cloud.common.core.util.IResponse;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * 抵押贷管理-资产修正
 *
 * @author 耿继辉
 */
@RestController
@Slf4j
@AllArgsConstructor
@ApiOperation("抵押贷管理-资产修正")
@RequestMapping("/afterMortgage")
public class AfterMortgageController {
    private final MortgageService mortgageService;
    /**
     * access_token
     */
    private final static String TOKEN = "";

    /**
     * 解抵押-解抵押列表查询-资产修正
     *
     * @param condition
     * @return
     */
    @ApiOperation("解抵押-解抵押列表查询-资产修正")
    @PostMapping("/getAfterMortgageList")
    public IResponse getAfterMortgageList(@RequestBody QueryCondition<MortgageCondition> condition) {
        IPage iPage = new Page();
//        MortgageDto mortgageDto = new MortgageDto();
//        mortgageDto.setPageIndex(condition.getPageNumber());
//        mortgageDto.setPageSize(condition.getPageSize());
//        //解抵押状态-status
//        mortgageDto.setStatus(condition.getCondition().getStatus());
//        if (condition.getCondition().getKey() != null) {
//            mortgageDto.setKey(condition.getCondition().getKey());
//        }
//        JSONObject afterMortgageList = this.mortgageService.getAfterMortgageList(mortgageDto);
//        JSONArray array = afterMortgageList.getJSONObject("data").getJSONArray("data");
//        //返回的data
//        iPage.setRecords(JSONObject.parseArray(array.toJSONString()));
//        iPage.setPages(afterMortgageList.getJSONObject("data").getInteger("pageIndex"));
//        iPage.setSize(afterMortgageList.getJSONObject("data").getInteger("pageSize"));
//        iPage.setTotal(afterMortgageList.getJSONObject("data").getInteger("recordsTotal"));
        return IResponse.success(iPage);
    }
}
